﻿@using ChGK.Data;

@{
    ViewBag.Title = "Организаторы";
    {
        Layout = "~/Views/Shared/_LayoutSuperuser.cshtml";
    }
}

<style type = "text/css">
.tinyTextBox 
{
    max-width: 1.5em;
}

.HiddenTextBox
{
    border-color : White;
    
}

table td
{
    border-color: Black;
}

table#half-hidden
{
    border-width: 0;
}
table td#hidden
{  
    border: 0;
}

</style>


<h2>@Model.Competition.Name, @Model.Competition.Type</h2>
<h4>@Model.Competition.Description</h4>
Список участников:
<table id = "half-hidden">
    <tr>
        <td>
            Номер
        </td>
        <td>
            Название
        </td>
        <td>
            Город
        </td>
    </tr>
    @if (ViewData["TeamID"] == null)
    {
        foreach (Team t in (IEnumerable<Team>)ViewData["Teams"])
        {
            <tr>
                <td align = "center">@t.Number</td>
                <td>@t.Caption</td>
                <td>@t.City</td>
                <td id = "hidden">@Html.ActionLink("изменить", "SuperuserPage", new { TeamID = t.ID })</td>
                <td id = "hidden">@Html.ActionLink("удалить", "DeleteTeam", new { TeamID = t.ID },
                    new { onclick = "return confirm('Вы уверены?');" })</td>
            </tr>
        }
    }
    else
    {
        foreach (Team t in (IEnumerable<Team>)ViewData["Teams"])
        {
            if (t.ID != (int)ViewData["TeamID"])
            {
                <tr>
                    <td>@t.Number</td>
                    <td>@t.Caption</td>
                    <td>@t.City</td>
                    <td id = "hidden">@Html.ActionLink("изменить", "SuperuserPage", new { TeamID = t.ID })</td>
                    <td id = "hidden">@Html.ActionLink("удалить", "DeleteTeam", new { TeamID = t.ID },
                        new { onclick = "return confirm('Вы уверены?');" })</td>
                </tr>
            }
            else
            {
                using (Html.BeginForm("EditTeam", "Superuser"))
                {
                @Html.Hidden("TeamID", ViewData["TeamID"])
                <tr>
                    <td>@Html.TextBox("TeamNumberNew", t.Number, new { @class = "tinyTextBox" })
                    @Html.Hidden("TeamNumberOld", t.Number)</td>
                    <td>@Html.TextBox("TeamName", t.Caption, new { @class = "HiddenTextBox" })</td>
                    <td>@Html.TextBox("TeamCity", t.City, new { @class = "HiddenTextBox" })</td>
                    <td id = "hidden"><input type = "submit", value = "Изменить" /></td>
                    <td id = "hidden">@Html.ValidationMessage("EditTeam")</td>
                </tr>
                }
            }
        }
    }
    
</table>
<br />
<br />
@using (Html.BeginForm("PreAddTeams", "Superuser"))
{
        <div>
            Добавить @Html.TextBox("NumberOfNewTeams", null, new { @class = "tinyTextBox" }) команд  
            <input type = "submit", value = "Добавить" />
            <br />
            @Html.ValidationMessage("NumberOfNewTeams")
        </div>
        
        
}
<br />
<br />
@using (Html.BeginForm("ShowLoginsAndPasswords", "Superuser"))
{
        <div>
            Показать логины и пароли команд.
            <br />
            Введите свой пароль:
            @Html.Password("SuperuserPassword")
            <input type = "submit", value = "Показать" />
            <br />
            @Html.ValidationMessage("SuperuserPassword")    
            </div>   
}
<br />
<br />
@using (Html.BeginForm("AddSuperuser", "Superuser"))
{       
        <div>
            Добавить аккаунт организатора.
            <br />
            Введите свой пароль:
            @Html.Password("SuperuserPassword")
            <input type = "submit", value = "Добавить" />
            <br />
            @Html.ValidationMessage("SuperuserPassword2")
        </div>  
            
}
<br />
<br />
@using (Html.BeginForm("DeleteUserCache", "Superuser"))
{
    <div>
        Разблокировать пользователя. 
        <br />
        Пожалуйста, введите логин пользователя:
        <br />
        @Html.TextBox("UserLogin")
        <input type = "submit", value = "Разблокировать" />
        <br />
        @Html.ValidationMessage("DeleteUserCache")
    </div>
}
<br />
<br />
@using (Html.BeginForm("FinalizeCompetition", "Superuser"))
{
    <div>
        @Html.CheckBox("IsEnded", (bool)Model.Competition.IsEnded)Турнир завершён, подведённые итоги объявляются окончательными. 
        <br />
        <br />
        <input type = "submit", value = "Подтвердить изменение">
        <br />
        @Html.ValidationMessage("FinalizeCompetition")
    </div>
}